package com.clickpaas.governmentcloud.controller.protalcontroller;

import com.alibaba.fastjson.JSONObject;
import com.clickpaas.governmentcloud.entity.portalentity.rep.*;
import com.clickpaas.governmentcloud.entity.portalentity.req.MenusReq;
import com.clickpaas.governmentcloud.service.portalservice.PortalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author 方延杰
 * @version 1.0
 * @since 2020/11/10 5:59 下午
 */
@Api(description = "页面展示")
@RequestMapping("/portal")
@RestController
public class PortalController {

    @Resource
    PortalService portalService;

    @ApiOperation("政策申报栏位详情")
    @PostMapping("/menus")
    public ResponseResult<MenusRep> menus(@RequestBody MenusReq menusReq) {
        return portalService.menus(menusReq);
    }

    @ApiOperation("最新政策")
    @GetMapping("/latestPolicysByPageInfo")
    public ResponseResult<List<LatestPolicy>> latestPolicyListByPageInfo(@ApiParam(name = "page", value = "当前页") @RequestParam(defaultValue = "1") Integer page,
                                                                         @ApiParam(name = "size", value = "每页大小(最小不能小于5)") @RequestParam(defaultValue = "10") Integer size) {
        return portalService.latestPolicyListByPageInfo(page, size);
    }

    @ApiOperation("主数据集(key为主数据名称)")
    @GetMapping("/mainDatas")
    public ResponseResult<Map<Object, Object>> mainDataList() {
        return portalService.mainDataList();
    }

    @ApiOperation("获取子领域数据根据行业")
    @PostMapping("/subDomainByIndustryIds")
    public ResponseResult<List<JSONObject>> subDomainListByIndustryIds(@ApiParam(name = "[\"1\",\"2\",\"3\"]", value = "String类型的数组") @RequestBody List<String> industryIds) {
        return portalService.subDomainListByIndustryIds(industryIds);
    }

    @ApiOperation("导语")
    @GetMapping("/introduction")
    public ResponseResult<Introduction> introduction() {
        return portalService.introduction();
    }

    @ApiOperation("政策数据中心")
    @GetMapping("/policyDataCenter")
    public ResponseResult<PolicyDataCenter> policyDataCenter() {
        return portalService.policyDataCenter();
    }




}
